#{extends 'common/supervisor.html' /}
#{set title:'权限管理' /}
<div class="xn_c_contentwarp">
  <div class="xn_c_contentlist">
    #{include "supervisor/systemSettings/common/leftBar.control"/}
    <div class="xn_c_content">
      <div class="xf_ht_tablelist">
        #{form @supervisor.systemSettings.rightAction.rightsManage(), id:'rightsManageList'}
        <input type="hidden" id="currPage" name="currPage"/>
	    <input type="hidden" id="pageSize" name="pageSize"/>
        <!-- 搜索 -->
        <div class="xf_ht_search_inon">
        <div class="xf_ht_search_r">
          <div class="xf_ht_search_xl">
          <input type="text" class="search_w" name="keyword" id="keyword" placeholder="权限组" value="${pageBean.conditions.keyword}"  style="width:150px">
          </div>
          <div class="xf_ht_search_xl">
          <input type="submit" class="search_button" value="搜索">
          </div>
        </div>
        </div>
        #{/form}
        <!-- 列表内容 -->
        <div class="xn_c_content_top">
        #{table class:"xn_c_content_list", cellspacing:"0", cellpadding:"0", border:"0", tr_class_odd:"xn_tr_bj"}
        #{tr}
          #{th}序号#{/th}
          #{th}权限组#{/th}
          #{th}权限组描述#{/th}
          #{th}用户数#{/th}
          #{th}操作#{/th}
        #{/tr}
        #{list pageBean?.page}         
        #{tr tr_index:_index}
          #{td}${(pageBean?.currPage - 1)*pageBean?.pageSize + _index}#{/td}
          #{td}${_?.name}#{/td}
          #{td}${_?.description}#{/td}
          #{td}${_?.supervisor_count}#{/td}
          #{td}
          #{if _?.id == 1}
          <span><a href="javascript:setGroupRosterInit(${_?.id})" id="lock" class="xf_ta_onclick">编辑权限组名单</a></span>
          #{/if}
          #{else}
          <span><a href="javascript:showEditWindow(${_?.id})" class="xf_ta_onclick">编辑</a></span>
          <span><a href="javascript:showSetRightsWindow(${_?.id})" class="xf_ta_onclick">权限设置</a></span>
          <span><a href="javascript:setGroupRosterInit(${_?.id})" id="lock" class="xf_ta_onclick">编辑权限组名单</a></span>
          <span><a href="javascript:deleteRightGroup(${_?.id})" id="delete" class="xf_ta_onclick">删除</a></span>
          #{/else}
          #{/td}
        #{/tr}
        #{/list}
        #{/table} 
        </div>
        <!-- 列表底部 -->
        <div class="xn_c_content_bottom">
          #{page currPage:pageBean.currPage,pageSize:pageBean.pageSize,totalCount:pageBean.totalCount,theme:2,style:4}keyword=${pageBean.conditions.keyword}#{/page}
          <input id="xf_dfk_fkzh_tcc3" type="button" class="xf_htbutton" onclick="showAddWindow();" value="添加权限组">
        </div>
      </div>
    </div>
  </div>
</div>

<!-- 编辑权限组-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc"></div>

<!-- 权限设置-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc2"></div>

<!-- 添加权限组-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc3"></div>

<!-- 编辑权限组名单-弹出层 -->
<div class="xn_c_ban_jox xn_c_ban_jox_qxsz" id="xf_ht_fkzh_ttc4"></div>

<!-- 选择管理员-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc5"></div>

<!-- 选择管理员名单-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc6"></div>

<script type="text/javascript">
  function showPage(currPage, pageSize){
    $("#currPage").val(currPage);
    $("#pageSize").val(pageSize);
    $("#rightsManageList").submit();
  }
  $(function() {
      /* 高亮显示 */
	  showHighLight(4,4,12);
  });
  
  
  var pop,pop2,pop3, pop31, pop32;

  //显示添加弹出层
  function showAddWindow() {
    $.ajax({
      url : "@{addRightGroupInit()}",
      type : "POST",
      data : {},
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);

          return;
        }
        var ttc = $("#xf_ht_fkzh_ttc3");
        ttc.html(data);
        pop = $.layer({
                type: 1,
                area: ['900', 'auto'],
                title: '添加权限组',
                page: {dom : ttc}
              });
      //  showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }

  //显示编辑弹出层
  function showEditWindow(groupId) {
    $.ajax({
      url : "@{editRightGroupInit()}",
      type : "POST",
      data : {
        "groupId" : groupId
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);

          return;
        }

        var ttc = $("#xf_ht_fkzh_ttc");
        ttc.html(data);
        $.layer({
          type: 1,
          area: ['900', 'auto'],
          title: '编辑权限组',
          page: {dom : ttc}
        });
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }

  //设置权限弹出层
  function showSetRightsWindow(groupId) {
    $.ajax({
      url : "@{setGroupRightsInit()}",
      type : "POST",
      data : {
        "groupId" : groupId
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);

          return;
        }

        var ttc = $("#xf_ht_fkzh_ttc2");
        ttc.html(data);
        pop2 = $.layer({
  type: 1,
  area: ['850', 'auto'],
  title: '权限设置',
  page: {dom : '#xf_ht_fkzh_ttc2'}
});
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
   
  //设置权限组名单
  function setGroupRosterInit(groupId) {
    $.ajax({
      url : "@{setGroupRosterInit()}",
      type : "POST",
      data : {
        "groupId" : groupId
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);

          return;
        }

        var ttc = $("#xf_ht_fkzh_ttc4");
        ttc.html(data);
        pop3 = $.layer({
           type: 1,
  area: ['700', 'auto'],
  title: '编辑权限组名单',
  page: {dom : '#xf_ht_fkzh_ttc4'}
});
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //删除权限组
  function deleteRightGroup(groupId) {
    if (!confirm("确认要删除？")) {
            return;
        }
    
    $.ajax({
      url : "@{deleteRightGroup()}",
      type : "POST",
      data : {
        "groupId" : groupId
      },
      success : function(data) {
        alert(data.msg);
        location.reload();
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }

  //搜索
  function search() {
    window.location.href = "rightsManage?keyword=" + encodeURIComponent($("#keyword").val());
  }
</script>

